﻿using DataPersonalization.Utis;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DataPersonalization
{
    public partial class frDomainError : Form
    {
        public frDomainError()
        {
            InitializeComponent();
            Grid_Init();
            Grid_Load();
        }

        private void Grid_Init()
        {
            #region cột Stt
            DataGridViewColumn colStt = new DataGridViewColumn(); // add a column to the grid
            DataGridViewCell cellStt = new DataGridViewTextBoxCell();

            colStt.CellTemplate = cellStt;

            colStt.HeaderText = "No";
            colStt.Name = "No";
            colStt.Visible = true;
            colStt.Width = 40;
            colStt.HeaderCell.Style.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            colStt.DefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            colStt.HeaderCell.Style.Font = new Font(this.Font, FontStyle.Bold);
            colStt.DataPropertyName = "No";

            grid.Columns.Add(colStt);
            #endregion

            #region cột Domain
            DataGridViewColumn colLnk = new DataGridViewColumn(); // add a column to the grid
            DataGridViewCell cellLnk = new DataGridViewTextBoxCell();
            colLnk.CellTemplate = cellLnk;
            colLnk.HeaderText = "Domain";
            colLnk.Name = "Domain";
            colLnk.Visible = true;
            colLnk.Width = 500;
            colLnk.HeaderCell.Style.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            colLnk.HeaderCell.Style.Font = new Font(this.Font, FontStyle.Bold);
            colLnk.DataPropertyName = "Domain";

            grid.Columns.Add(colLnk);
            #endregion

            #region cột status
            DataGridViewColumn colStatus = new DataGridViewColumn(); // add a column to the grid
            DataGridViewCell cellStatus = new DataGridViewTextBoxCell();
            colStatus.CellTemplate = cellStatus;
            colStatus.HeaderText = "Note";
            colStatus.Name = "Note";
            colStatus.Visible = true;
            colStatus.Width = 200;
            colStatus.HeaderCell.Style.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            colStatus.DefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            colStatus.HeaderCell.Style.Font = new Font(this.Font, FontStyle.Bold);
            colStatus.DataPropertyName = "Note";

            grid.Columns.Add(colStatus);
            #endregion

            grid.AutoGenerateColumns = false;
        }

        private void Grid_Load()
        {
            MyUtis utis = new MyUtis();
            List<DomainEntity> ls = utis.GetListDomainError();

            grid.SelectionMode = DataGridViewSelectionMode.CellSelect;
            grid.MultiSelect = false;

            grid.AutoGenerateColumns = false;
            grid.DataSource = ls;
        }

        private void btRefresh_Click(object sender, EventArgs e)
        {
            Grid_Load();
        }

    }
}
